﻿namespace Vin.Extension.Redis.Entities;

public class GeoSearchResult
{
    /// <summary>
    /// 成员
    /// </summary>
    public string Member { get; set; }

    /// <summary>
    /// 距离
    /// </summary>
    public decimal? Distance { get; set; }

    /// <summary>
    /// 哈希
    /// </summary>
    public decimal? Hash { get; set; }

    /// <summary>
    /// 经度
    /// </summary>
    public decimal? Longitude { get; set; }

    /// <summary>
    /// 纬度
    /// </summary>
    public decimal? Latitude { get; set; }

    public GeoSearchResult(string member)
    {
        Member = member;
    }
}

/// <summary>
/// 地理位置搜索类型
/// </summary>
public class GeoSearchType
{
    /// <summary>
    /// 搜索类型
    /// </summary>
    public SearchType Type { get; set; }

    /// <summary>
    /// 成员
    /// </summary>
    public string? Member { get; set; }

    /// <summary>
    /// 经度
    /// </summary>
    public decimal? Lon { get; set; }

    /// <summary>
    /// 纬度
    /// </summary>
    public decimal? Lat { get; set; }

    public GeoSearchType(decimal lon, decimal lat)
    {
        Type = SearchType.Fromlonlat;
        Lon = lon;
        Lat = lat;
    }

    public GeoSearchType(string member)
    {
        Type = SearchType.Frommember;
        Member = member;
    }

    public enum SearchType
    {
        /// <summary>
        /// 从成员
        /// </summary>
        Frommember,

        /// <summary>
        /// 从经纬度
        /// </summary>
        Fromlonlat
    }
}

/// <summary>
/// 地理位置搜索形状
/// </summary>
public class GeoSearchShape
{
    /// <summary>
    /// 形状
    /// </summary>
    public SearchShape Shape { get; set; }

    /// <summary>
    /// 半径
    /// </summary>
    public decimal? Radius { get; set; }

    /// <summary>
    /// 宽度
    /// </summary>
    public decimal? Width { get; set; }

    /// <summary>
    /// 高度
    /// </summary>
    public decimal? Height { get; set; }

    public GeoSearchShape(decimal radius)
    {
        Shape = SearchShape.Byradius;
        Radius = radius;
    }

    public GeoSearchShape(decimal width, decimal height)
    {
        Shape = SearchShape.Bybox;
        Width = width;
        Height = height;
    }

    public enum SearchShape
    {
        /// <summary>
        /// 通过半径
        /// </summary>
        Byradius,

        /// <summary>
        /// 通过矩形
        /// </summary>
        Bybox,
    }
}

/// <summary>
/// 地理位置搜索计数
/// </summary>
public class GeoSearchPage
{
    /// <summary>
    /// 页码
    /// </summary>
    public int Page { get; set; } = 1;

    /// <summary>
    /// 页大小
    /// </summary>
    public int PageSize { get; set; } = 10;

    /// <summary>
    /// 总数
    /// </summary>
    public int TotalCount { get; set; }
}